import os
import pytest
from threading import Thread
from multiprocessing import Process
import time

def func(i):
    print('我是线程{}'.format(i))
    pytest.main(["./shargeTestCase/sign_test.py",
                 "-sv", "--alluredir", "./testoutput/json"])
    os.system("allure generate ./testoutput/json -o ./testoutput/report --clean")


if __name__ == '__main__':

    # start = time.time()
    # t_li = []
    # for i in range(1):  # 10个线程
    #     t = Thread(target=func, args=(i,))
    #     t.start()
    #     t_li.append(t)
    # for t in t_li:
    #     t.join()
    # tt = time.time() - start
    # print('启动100个线程需要：%s' % tt)  # 启动100个线程需要：0.012004613876342773

    start2 = time.time()
    p_li = []
    for i in range(10):  # 100个子进程
        p = Process(target=func, args=(i,))
        p.start()
        p_li.append(p)
    for p in p_li:
        p.join()
    pp = time.time() - start2
    print('启动100个进程需要：%s' % pp)  # 启动100个进程需要：1.3103454113006592